package com.visec.hdy.transmission.socket.code;

import java.io.BufferedInputStream;
import java.io.Closeable;
import java.nio.charset.Charset;

public interface SocketClient extends Closeable {

	public void monitor(String monitorId, Monitor m);
	
	public boolean isConnected();
	
	public boolean isClosed();

	public void clearMonitor(String monitorId);

	public SocketClient copy();

	public void clearMonitors();
	
	public boolean connect() throws Exception;

	public void openInput();

	public void closeInput();

	public int read(byte[] b);
	
	public BufferedInputStream getInput();

	public void openOutput();

	public void closeOutput();

	public void write(byte[] b) throws Exception;
	
	public Charset getCharset();

	public void write(byte[] b, int start, int length) throws Exception;

	public void write(String s) throws Exception;
	
	public void writeCompletion(String s) throws Exception;

	public interface Monitor {

		public boolean handle(byte[] data, int start, int length);

	}

}
